﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using Arizu.Repository;

namespace AiRiZu.User
{
    public class ChangePassword1 : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["logId"] == null)
            {
                return;
            }

            AirizuUser airizuUser = AirizuUser.CreateInstance();

            if (context.Request.Params["newPsw"] == null)
            {
                return;
            }

            airizuUser.ChangePassword(long.Parse(context.Session["logId"].ToString()), context.Request.Params["newPsw"].ToString());

            //context.Response.ContentType = "text/plain";
            string url = context.Request.Url.ToString().Replace("ashx", "aspx");
            context.Response.Redirect(url); 
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
